package com.htudata.item.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.htudata.common.service.DataEhcacheService;
import com.htudata.node.service.impl.NodeShowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ItemServiceDemo {

  @Autowired
  private DataEhcacheService dataEhcacheService;
  
  public Object showOrHideItems(String nodeId, int isShowed, String a2) {
    Map<String, Object> result = new HashMap<>();
    result.put("result", Integer.valueOf(1));
    return result;
  }
  
  public List<Map<String, Object>> getItems(String flowId, String nodeId, String a2) {
    if (!NodeShowService.isValidFlowIdId(flowId) && nodeId.equals("-1"))
      return Collections.EMPTY_LIST; 
    Map<String, Object> map1 = new HashMap<>();
    map1.put("itemId", Integer.valueOf(1));
    map1.put("name", "CPU利用率");
    map1.put("value", (56 + (int)(Math.random() * 10.0D)) + "%");
    map1.put("color", "#ffffff");
    map1.put("isShowed", Integer.valueOf(1));
    Map<String, Object> map2 = new HashMap<>();
    map2.put("itemId", Integer.valueOf(2));
    map2.put("name", "内存利用率");
    map2.put("value", (86 + (int)(Math.random() * 10.0D)) + "%");
    map2.put("color", "#cd2920");
    map2.put("isShowed", Integer.valueOf(1));
    Map<String, Object> map3 = new HashMap<>();
    map3.put("itemId", Integer.valueOf(3));
    map3.put("name", "存储容量");
    map3.put("value", (25 + (int)(Math.random() * 10.0D)) + "G");
    map3.put("color", "#ffffff");
    map3.put("isShowed", Integer.valueOf(1));
    List<Map<String, Object>> list1 = new ArrayList<>();
    list1.add(map1);
    list1.add(map2);
    list1.add(map3);
    if (!NodeShowService.isValidFlowIdId(flowId) && !nodeId.equals("-1"))
      return list1; 
    map1.put("state", Boolean.valueOf(true));
    map2.put("state", Boolean.valueOf(true));
    map3.put("state", Boolean.valueOf(true));
    Map<String, Object> map4 = new HashMap<>();
    map4.put("itemId", Integer.valueOf(4));
    map4.put("name", "系统进程状态是否正常");
    map4.put("value", "是");
    map4.put("state", Boolean.valueOf(true));
    map4.put("color", "#ffffff");
    map1.put("isShowed", Integer.valueOf(1));
    Map<String, Object> map5 = new HashMap<>();
    map5.put("itemId", Integer.valueOf(5));
    map5.put("name", "监视服务端SOCKET服务是否存活");
    map5.put("value", "否");
    map5.put("state", Boolean.valueOf(true));
    map5.put("color", "#cd2920");
    map5.put("isShowed", Integer.valueOf(0));
    List<Map<String, Object>> list2 = new ArrayList<>();
    list2.add(map4);
    list2.add(map5);
    Map<String, Object> map6 = new HashMap<>();
    map6.put("itemId", Integer.valueOf(6));
    map6.put("name", "消息转发率");
    map6.put("value", (25 + (int)(Math.random() * 10.0D)) + "%");
    map6.put("state", Boolean.valueOf(true));
    map6.put("color", "#ffffff");
    map6.put("isShowed", Integer.valueOf(1));
    Map<String, Object> map7 = new HashMap<>();
    map7.put("itemId", Integer.valueOf(7));
    map7.put("name", "消息平均延时");
    map7.put("value", (1 + (int)(Math.random() * 2.0D)) + "m");
    map7.put("state", Boolean.valueOf(true));
    map7.put("color", "#ffffff");
    map7.put("isShowed", Integer.valueOf(1));
    List<Map<String, Object>> list3 = new ArrayList<>();
    list3.add(map6);
    list3.add(map7);
    Map<String, Object> map8 = new HashMap<>();
    map8.put("itemId", Integer.valueOf(8));
    map8.put("name", "分钟入库量");
    map8.put("value", (200 + (int)(Math.random() * 10.0D)) + "包");
    map8.put("state", Boolean.valueOf(true));
    map8.put("color", "#ffffff");
    map8.put("isShowed", Integer.valueOf(0));
    Map<String, Object> map9 = new HashMap<>();
    map9.put("itemId", Integer.valueOf(9));
    map9.put("name", "小时入库量");
    map9.put("value", (1.8D + (int)(Math.random() * 10.0D)) + "万包");
    map9.put("state", Boolean.valueOf(true));
    map9.put("color", "#ffffff");
    map9.put("isShowed", Integer.valueOf(0));
    Map<String, Object> map10 = new HashMap<>();
    map10.put("itemId", Integer.valueOf(10));
    map10.put("name", "入库平均耗时");
    map10.put("value", (5 + (int)(Math.random() * 10.0D)) + "s");
    map10.put("state", Boolean.valueOf(true));
    map10.put("color", "#ffffff");
    map10.put("isShowed", Integer.valueOf(0));
    List<Map<String, Object>> list4 = new ArrayList<>();
    list4.add(map8);
    list4.add(map9);
    list4.add(map10);
    List<Map<String, Object>> result = new ArrayList<>();
    Map<String, Object> m1 = new HashMap<>();
    m1.put("name", "数据采集处理服务器");
    m1.put("list", list1);
    m1.put("state", Boolean.valueOf(true));
    m1.put("type", Integer.valueOf(1));
    Map<String, Object> m2 = new HashMap<>();
    m2.put("name", "市局接收服务器");
    m2.put("list", list2);
    m2.put("state", Boolean.valueOf(true));
    m2.put("type", Integer.valueOf(1));
    Map<String, Object> m3 = new HashMap<>();
    m3.put("name", "消息中间件服务器");
    m3.put("list", list3);
    m3.put("state", Boolean.valueOf(true));
    m3.put("type", Integer.valueOf(5));
    Map<String, Object> m4 = new HashMap<>();
    m4.put("name", "数据入库服务器");
    m4.put("list", list4);
    m4.put("state", Boolean.valueOf(true));
    m4.put("type", Integer.valueOf(3));
    List<Map<String, Object>> list5 = new ArrayList<>();
    list5.add(m1);
    Map<String, Object> map12 = new HashMap<>();
    map12.put("name", "服务器");
    map12.put("list", list5);
    map12.put("type", Integer.valueOf(1));
    map12.put("state", Boolean.valueOf(true));
    List<Map<String, Object>> list6 = new ArrayList<>();
    list6.add(map12);
    Map<String, Object> map13 = new HashMap<>();
    map13.put("name", "基础资源");
    map13.put("list", list6);
    map13.put("type", Integer.valueOf(1));
    map13.put("state", Boolean.valueOf(true));
    result.add(map13);
    list5 = new ArrayList<>();
    list5.add(m2);
    map12 = new HashMap<>();
    map12.put("name", "服务器");
    map12.put("list", list5);
    map12.put("type", Integer.valueOf(1));
    map12.put("state", Boolean.valueOf(true));
    list6 = new ArrayList<>();
    list6.add(map12);
    map13 = new HashMap<>();
    map13.put("name", "系统服务");
    map13.put("list", list6);
    map13.put("type", Integer.valueOf(2));
    map13.put("state", Boolean.valueOf(true));
    result.add(map13);
    list5 = new ArrayList<>();
    list5.add(m3);
    map12 = new HashMap<>();
    map12.put("name", "消息中间件");
    map12.put("list", list5);
    map12.put("type", Integer.valueOf(5));
    map12.put("state", Boolean.valueOf(true));
    list6 = new ArrayList<>();
    list6.add(map12);
    map13 = new HashMap<>();
    map13.put("name", "软件服务");
    map13.put("list", list6);
    map13.put("type", Integer.valueOf(3));
    map13.put("state", Boolean.valueOf(true));
    result.add(map13);
    list5 = new ArrayList<>();
    list5.add(m4);
    map12 = new HashMap<>();
    map12.put("name", "服务器");
    map12.put("list", list5);
    map12.put("type", Integer.valueOf(1));
    map12.put("state", Boolean.valueOf(true));
    list6 = new ArrayList<>();
    list6.add(map12);
    map13 = new HashMap<>();
    map13.put("name", "业务指标");
    map13.put("list", list6);
    map13.put("type", Integer.valueOf(4));
    map13.put("state", Boolean.valueOf(true));
    result.add(map13);
    return result;
  }
  
  public Map<String, Object> postItems(JSONObject params, String a2) {
    JSONArray itemIds = params.getJSONArray("itemIds");
    this.dataEhcacheService.putValueToCache("postItems", itemIds);
    Map<String, Object> result = new HashMap<>();
    result.put("result", Integer.valueOf(1));
    return result;
  }
  
  public List<Map<String, Object>> getItemData(String flowId, String nodeId, String a2) {
    if (!NodeShowService.isValidFlowIdId(flowId) && nodeId.equals("-1"))
      return Collections.EMPTY_LIST; 
    Map<String, Object> map1 = new HashMap<>();
    map1.put("itemId", Integer.valueOf(1));
    map1.put("name", "CPU利用率");
    map1.put("value", (56 + (int)(Math.random() * 10.0D)) + "%");
    map1.put("color", "#ffffff");
    Map<String, Object> map2 = new HashMap<>();
    map2.put("itemId", Integer.valueOf(2));
    map2.put("name", "内存利用率");
    map2.put("value", (86 + (int)(Math.random() * 10.0D)) + "%");
    map2.put("color", "#cd2920");
    Map<String, Object> map3 = new HashMap<>();
    map3.put("itemId", Integer.valueOf(3));
    map3.put("name", "存储容量");
    map3.put("value", (25 + (int)(Math.random() * 10.0D)) + "G");
    map3.put("color", "#ffffff");
    List<Map<String, Object>> list1 = new ArrayList<>();
    list1.add(map1);
    list1.add(map2);
    list1.add(map3);
    if (!NodeShowService.isValidFlowIdId(flowId) && !nodeId.equals("-1"))
      return list1; 
    map1.put("state", Boolean.valueOf(true));
    map2.put("state", Boolean.valueOf(true));
    map3.put("state", Boolean.valueOf(true));
    Map<String, Object> map4 = new HashMap<>();
    map4.put("itemId", Integer.valueOf(4));
    map4.put("name", "系统进程状态是否正常");
    map4.put("value", "是");
    map4.put("state", Boolean.valueOf(true));
    map4.put("color", "#ffffff");
    Map<String, Object> map5 = new HashMap<>();
    map5.put("itemId", Integer.valueOf(5));
    map5.put("name", "监视服务端SOCKET服务是否存活");
    map5.put("value", "否");
    map5.put("state", Boolean.valueOf(true));
    map5.put("color", "#cd2920");
    List<Map<String, Object>> list2 = new ArrayList<>();
    list2.add(map4);
    list2.add(map5);
    Map<String, Object> map6 = new HashMap<>();
    map6.put("itemId", Integer.valueOf(6));
    map6.put("name", "消息转发率");
    map6.put("value", (25 + (int)(Math.random() * 10.0D)) + "%");
    map6.put("state", Boolean.valueOf(true));
    map6.put("color", "#ffffff");
    Map<String, Object> map7 = new HashMap<>();
    map7.put("itemId", Integer.valueOf(7));
    map7.put("name", "消息平均延时");
    map7.put("value", (1 + (int)(Math.random() * 2.0D)) + "m");
    map7.put("state", Boolean.valueOf(true));
    map7.put("color", "#ffffff");
    List<Map<String, Object>> list3 = new ArrayList<>();
    list3.add(map6);
    list3.add(map7);
    Map<String, Object> map8 = new HashMap<>();
    map8.put("itemId", Integer.valueOf(8));
    map8.put("name", "分钟入库量");
    map8.put("value", (200 + (int)(Math.random() * 10.0D)) + "包");
    map8.put("state", Boolean.valueOf(true));
    map8.put("color", "#ffffff");
    Map<String, Object> map9 = new HashMap<>();
    map9.put("itemId", Integer.valueOf(9));
    map9.put("name", "小时入库量");
    map9.put("value", (1.8D + (int)(Math.random() * 10.0D)) + "万包");
    map9.put("state", Boolean.valueOf(true));
    map9.put("color", "#ffffff");
    Map<String, Object> map10 = new HashMap<>();
    map10.put("itemId", Integer.valueOf(10));
    map10.put("name", "入库平均耗时");
    map10.put("value", (5 + (int)(Math.random() * 10.0D)) + "s");
    map10.put("state", Boolean.valueOf(true));
    map10.put("color", "#ffffff");
    List<Map<String, Object>> list4 = new ArrayList<>();
    list4.add(map8);
    list4.add(map9);
    list4.add(map10);
    List<Map<String, Object>> result = new ArrayList<>();
    Map<String, Object> m1 = new HashMap<>();
    m1.put("name", "数据采集处理服务器");
    m1.put("list", list1);
    m1.put("state", Boolean.valueOf(true));
    m1.put("type", Integer.valueOf(1));
    Map<String, Object> m2 = new HashMap<>();
    m2.put("name", "市局接收服务器");
    m2.put("list", list2);
    m2.put("state", Boolean.valueOf(true));
    m2.put("type", Integer.valueOf(1));
    Map<String, Object> m3 = new HashMap<>();
    m3.put("name", "消息中间件服务器");
    m3.put("list", list3);
    m3.put("state", Boolean.valueOf(true));
    m3.put("type", Integer.valueOf(5));
    Map<String, Object> m4 = new HashMap<>();
    m4.put("name", "数据入库服务器");
    m4.put("list", list4);
    m4.put("state", Boolean.valueOf(true));
    m4.put("type", Integer.valueOf(3));
    List<Map<String, Object>> list5 = new ArrayList<>();
    list5.add(m1);
    Map<String, Object> map12 = new HashMap<>();
    map12.put("name", "服务器");
    map12.put("list", list5);
    map12.put("state", Boolean.valueOf(true));
    map12.put("type", Integer.valueOf(1));
    List<Map<String, Object>> list6 = new ArrayList<>();
    list6.add(map12);
    Map<String, Object> map13 = new HashMap<>();
    map13.put("num", Integer.valueOf(43));
    map13.put("name", "基础资源");
    map13.put("list", list6);
    map13.put("state", Boolean.valueOf(true));
    map13.put("type", Integer.valueOf(1));
    result.add(map13);
    list5 = new ArrayList<>();
    list5.add(m2);
    map12 = new HashMap<>();
    map12.put("name", "服务器");
    map12.put("list", list5);
    map12.put("state", Boolean.valueOf(true));
    map12.put("type", Integer.valueOf(1));
    list6 = new ArrayList<>();
    list6.add(map12);
    map13 = new HashMap<>();
    map13.put("num", Integer.valueOf(86));
    map13.put("name", "系统服务");
    map13.put("list", list6);
    map13.put("state", Boolean.valueOf(true));
    map13.put("type", Integer.valueOf(2));
    result.add(map13);
    list5 = new ArrayList<>();
    list5.add(m3);
    map12 = new HashMap<>();
    map12.put("name", "消息中间件");
    map12.put("list", list5);
    map12.put("state", Boolean.valueOf(true));
    map12.put("type", Integer.valueOf(5));
    list6 = new ArrayList<>();
    list6.add(map12);
    map13 = new HashMap<>();
    map13.put("num", Integer.valueOf(46));
    map13.put("name", "软件服务");
    map13.put("list", list6);
    map13.put("state", Boolean.valueOf(true));
    map13.put("type", Integer.valueOf(3));
    result.add(map13);
    list5 = new ArrayList<>();
    list5.add(m4);
    map12 = new HashMap<>();
    map12.put("name", "服务器");
    map12.put("list", list5);
    map12.put("state", Boolean.valueOf(true));
    map12.put("type", Integer.valueOf(1));
    list6 = new ArrayList<>();
    list6.add(map12);
    map13 = new HashMap<>();
    map13.put("num", Integer.valueOf(50));
    map13.put("name", "业务指标");
    map13.put("list", list6);
    map13.put("state", Boolean.valueOf(true));
    map13.put("type", Integer.valueOf(4));
    result.add(map13);
    List<Map<String, Object>> list55 = new ArrayList<>();
    List<Map<String, Object>> list66 = new ArrayList<>();
    List<Map<String, Object>> list7 = new ArrayList<>();
    List<Map<String, Object>> list8 = new ArrayList<>();
    try {
      JSONArray itemIds = (JSONArray)this.dataEhcacheService.getValueFromCache("postItems");
      if (itemIds.isEmpty())
        return result; 
      for (Map<String, Object> temp : list1) {
        for (Object itemId : itemIds) {
          if (temp.get("itemId").equals(Integer.valueOf(((Integer)itemId).intValue())))
            list55.add(temp); 
        } 
      } 
      for (Map<String, Object> temp : list2) {
        for (Object itemId : itemIds) {
          if (temp.get("itemId").equals(itemId + ""))
            list66.add(temp); 
        } 
      } 
      for (Map<String, Object> temp : list3) {
        for (Object itemId : itemIds) {
          if (temp.get("itemId").equals(itemId + ""))
            list7.add(temp); 
        } 
      } 
      for (Map<String, Object> temp : list4) {
        for (Object itemId : itemIds) {
          if (temp.get("itemId").equals(itemId + ""))
            list8.add(temp); 
        } 
      } 
      result = new ArrayList<>();
      list5 = new ArrayList<>();
      list5.add(m1);
      map12 = new HashMap<>();
      map12.put("name", "服务器");
      map12.put("list", list55);
      map12.put("state", Boolean.valueOf(true));
      map12.put("type", Integer.valueOf(1));
      list6 = new ArrayList<>();
      list6.add(map12);
      map13 = new HashMap<>();
      map13.put("num", Integer.valueOf(43));
      map13.put("name", "基础资源");
      map13.put("list", list6);
      map13.put("state", Boolean.valueOf(true));
      map13.put("type", Integer.valueOf(1));
      result.add(map13);
      list5 = new ArrayList<>();
      list5.add(m2);
      map12 = new HashMap<>();
      map12.put("name", "服务器");
      map12.put("list", list66);
      map12.put("state", Boolean.valueOf(true));
      map12.put("type", Integer.valueOf(1));
      list6 = new ArrayList<>();
      list6.add(map12);
      map13 = new HashMap<>();
      map13.put("num", Integer.valueOf(86));
      map13.put("name", "系统服务");
      map13.put("list", list6);
      map13.put("state", Boolean.valueOf(true));
      map13.put("type", Integer.valueOf(2));
      result.add(map13);
      list5 = new ArrayList<>();
      list5.add(m3);
      map12 = new HashMap<>();
      map12.put("name", "消息中间件");
      map12.put("list", list7);
      map12.put("state", Boolean.valueOf(true));
      map12.put("type", Integer.valueOf(5));
      list6 = new ArrayList<>();
      list6.add(map12);
      map13 = new HashMap<>();
      map13.put("num", Integer.valueOf(46));
      map13.put("name", "软件服务");
      map13.put("list", list6);
      map13.put("state", Boolean.valueOf(true));
      map13.put("type", Integer.valueOf(3));
      result.add(map13);
      list5 = new ArrayList<>();
      list5.add(m4);
      map12 = new HashMap<>();
      map12.put("name", "服务器");
      map12.put("list", list8);
      map12.put("state", Boolean.valueOf(true));
      map12.put("type", Integer.valueOf(1));
      list6 = new ArrayList<>();
      list6.add(map12);
      map13 = new HashMap<>();
      map13.put("num", Integer.valueOf(50));
      map13.put("name", "业务指标");
      map13.put("list", list6);
      map13.put("state", Boolean.valueOf(true));
      map13.put("type", Integer.valueOf(4));
      result.add(map13);
    } catch (Exception exception) {}
    return result;
  }
}
